﻿
(function () {
    appModule.controller('tenant.views.announcement.sendAnnouncement', [
        '$scope', '$uibModalInstance', '$uibModal', 'abp.services.app.announcement', 'appSession',
        function ($scope, $uibModalInstance, $modal, announcementService,appSession) {
            var vm = this;
            vm.title = "";
            vm.content = "";
            vm.saving = false;
            vm.announcement = null;
            vm.users = "";
            vm.ids = [];
            vm.save = function () {
                announcementService.sendAnnouncement({ title: vm.title, content: vm.content, userid: appSession.user.id, ids: vm.ids }).success(function () {
                    abp.notify.info("信息发送成功！");
                    $uibModalInstance.close();
                }).finally(function () {
                    vm.saving = false;
                });
            };
            vm.cancel = function () {
                $uibModalInstance.dismiss();
            };
            vm.getUsers = function () {
                var modalInstance = $modal.open({
                    templateUrl: '~/App/tenant/views/announcement/users.cshtml',
                    controller: 'tenant.views.announcement.users as vm',
                    backdrop: 'static',
                    resolve: {

                    }
                });

                modalInstance.result.then(function (result) {
                    vm.users = result.userStr;
                    vm.ids = result.ids;
                });
            }
        }
    ]);
})();
